<template>
  <div class="date-search">
    <div class="time-row">
      <div class="label">申请日期：</div>
      <el-date-picker
        v-model="applyTimeRange"
        type="daterange"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
        value-format="yyyy-MM-dd"
        class="timeSelect"
        popper-class="timeSelectPopup"
      ></el-date-picker>
    </div>
    <div class="time-row">
      <div class="label">审核日期：</div>
      <el-date-picker
        v-model="auditTimeRange"
        type="daterange"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
        value-format="yyyy-MM-dd"
        class="timeSelect"
        popper-class="timeSelectPopup"
      ></el-date-picker>
    </div>
    <div class="btn-row">
      <div class="reset-btn" @click="reset">重置</div>
      <div class="save-btn" @click="save">确定</div>
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
import moment from 'moment'
export default {
  components: {
  },
  name: "",
  props: {
    nowApplyTimeStart: {
      type: String,
      default: '',
    },
    nowApplyTimeEnd: {
      type: String,
      default: '',
    },
    nowAuditTimeStart: {
      type: String,
      default: '',
    },
    nowAuditTimeEnd: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      applyTimeRange: ['',''],
      auditTimeRange: ['',''],
    }
  },
  computed: {
  },
  mounted() {
    this.applyTimeRange = [this.nowApplyTimeStart, this.nowApplyTimeEnd]
    this.auditTimeRange = [this.nowAuditTimeStart, this.nowAuditTimeEnd]
    this.$forceUpdate()
  },
  methods: {
    reset() {
      this.applyTimeRange = ['','']
      this.auditTimeRange = ['','']
    },
    save() {
      this.$emit('save',this.applyTimeRange[0],this.applyTimeRange[1],this.auditTimeRange[0],this.auditTimeRange[1])
    },
  },
};
</script>
<style>
.timeSelectPopup {
  z-index: 100001 !important;
}
</style>
<style lang="less" scoped>
@textColor: #1f1e1d;
@ntalkColor: #e67529;
.date-search {
  position: absolute;
  top: 28px;
  right: 0;
  width: 426px;
  box-sizing: border-box;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0px 6px 16px 0px rgba(0, 0, 0, 0.08),0px 3px 6px -4px rgba(0, 0, 0, 0.12),0px 9px 28px 8px rgba(0, 0, 0, 0.05);
  z-index: 100000;

  .time-row {
    display: flex;
    align-items: center;
    box-sizing: border-box;
    padding: 0 16px;
    margin-top: 16px;
    .label {
      font-size: 14px;
      line-height: 22px;
      color: @textColor;
      width: 72px;
      flex-shrink: 0;
    }
    .timeSelect {
      width: calc(100% - 72px);
      height: 32px;
      line-height: 32px;
      /deep/ .el-range__icon {
        margin-top: -8px;
      }
      /deep/ .el-range-separator {
        margin-top: -8px;
        width: 6%;
      }
      /deep/ .el-range__close-icon {
        margin-top: -8px;
      }
    }
    /deep/ .el-range-editor.is-active, .el-range-editor.is-active:hover, .el-select .el-input.is-focus .el-input__inner {
      border-color: @ntalkColor;
    }
  }

  .btn-row {
    width: 100%;
    box-sizing: border-box;
    padding: 16px;
    display: flex;
    justify-content: flex-end;
    .reset-btn {
      width: 60px;
      height: 32px;
      box-sizing: border-box;
      font-size: 14px;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      border-radius: 6px;
      color: @textColor;
      background-color: #ededed;
      margin-right: 8px;
    }
    .save-btn {
      width: 60px;
      height: 32px;
      box-sizing: border-box;
      font-size: 14px;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      border-radius: 6px;
      background-color: @ntalkColor;
      color: #fff;
    }
  }
}
</style>
